using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InduMall.Core.Models.Mapping
{
    public class DiscountProductMap : EntityTypeConfiguration<DiscountProduct>
    {
        public DiscountProductMap()
        {
            // Primary Key
            this.HasKey(t => t.DiscountProduct1);

            // Properties
            this.Property(t => t.DiscountProduct1)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("DiscountProduct");
            this.Property(t => t.DiscountProduct1).HasColumnName("DiscountProduct");
            this.Property(t => t.ProductId).HasColumnName("ProductId");
            this.Property(t => t.Discount).HasColumnName("Discount");
            this.Property(t => t.PublishedDate).HasColumnName("PublishedDate");
            this.Property(t => t.ExpireationDate).HasColumnName("ExpireationDate");

            // Relationships
            this.HasRequired(t => t.Product)
                .WithMany(t => t.DiscountProducts)
                .HasForeignKey(d => d.ProductId);

        }
    }
}
